﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Peak.Core;
using Peak.Resources;

namespace Peak.Web.Controllers.Models
{
  public class DashboardModel
  {
    public List<UserActivityModel> Activities { get; set; }

    public DashboardFilterModel Filter { get; set; }
    
    public List<DashboardItem> Items { get; set; }

    public IList<User> Users { get; set; }

    public DashboardModel(DashboardFilterModel filter,IList<User> users, List<UserActivityModel> activities)
    {
      Filter = filter;  
      Items = new List<DashboardItem>();
      Users = users;
      Activities = activities;
    }    

    public void AddTasks(IEnumerable<Task> tasks)
    {
      foreach (Task task in tasks)
      {
        Items.Add(new DashboardItem(task,Filter.CurrentSprintOnly));
      }
    }

    public void Sort()
    {
      Items = Items.OrderByDescending(f => f.Story.Priority).OrderBy(f=>f.Path).ToList();
    }
  }
}
